<template>
  <div class="oaLogin" v-loading="loading"></div>
</template>


<script>
import { mapMutations } from 'vuex'
export default {
  name: 'oaLogin',
  data() {
    return {
      loading: true
    }
  },
  methods: {
    ...mapMutations(['changeLogin']),
  },
  created() {
    const query = this.$route.query
    if (query.code) {
      this.$post('/operation/empower/tele', { code: query.code }).then(res => {
        if (res.code === 200) {
          this.$cookies.set("authorizationYgd", res.data["access_token"], res.data["expires_in"], "/");
          this.$cookies.set("access_token_ygd", res.data["access_token"], "/");
          this.changeLogin({ authorization: res.data["access_token"], })
          sessionStorage.setItem('oaLogin', true)
          this.$router.push("/login");
        } else {
          this.$router.push("/login");
        }
      })
    } else {
      this.$router.push("/login");
    }
  },
}
</script>

<style lang="scss" scoped>
.oaLogin {
  width: 100%;
  height: 100%;
}
</style>